<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改</title>
    <link rel="stylesheet" href="../../layui/css/layui.css"/>
    <script src="../../layui/layui.js"></script>
    <script>
        layui.use('element', function() {
            var $ = layui.jquery;  //加载jQuery模块
            var element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
        });
    </script>
</head>
<body>

 <form class="layui-form">
     <div class="layui-form-item">
         <label class="layui-form-label">编号</label>
         <div class="layui-input-inline">
             <input type="number" name="num" placeholder="" required readonly lay-verify="required" class="layui-input" >
         </div>
         <input type="hidden" name="jointime"  class="layui-input" >

         <label class="layui-form-label">姓名</label>
         <div class="layui-input-inline">
             <input type="text" name="name" placeholder="" required lay-verify="required" class="layui-input" >
         </div>

         <label class="layui-form-label">性别</label>
         <div class="layui-input-inline">

             <input type="radio" name="sex" value="男" title="男" checked class="layui-input">
             <input type="radio" name="sex" value="女" title="女" class="layui-input">
         </div>
     </div>
     <div class="layui-form-item">
     <label class="layui-form-label">出生日期</label>
     <div class="layui-input-inline">
         <input type="text" name="birthday" id="date2"  placeholder="" autocomplete="off" class="layui-input">
     </div>
     </div>
     <div class="layui-form-item">
         <label class="layui-form-label">联系方式</label>
         <div class="layui-input-inline">
             <input type="text" name="phone" lay-verify="required" autocomplete="off" placeholder="" class="layui-input">
         </div>

     </div>
     <div class="layui-form-item">
         <label class="layui-form-label">积分</label>
         <div class="layui-input-inline">
             <input type="text" name="cpoint" placeholder="" required lay-verify="required" class="layui-input" >
         </div>
     </div>



     <div class="layui-form-item">
         <div class="layui-input-block">
             <button id="loginBtn" class="layui-btn" lay-submit lay-filter="add">修改</button>
         </div>
     </div>
 </form>


 <script>
     layui.use(['upload', 'element', 'layer','form','laydate'], function() {
         var $ = layui.jquery
             , upload = layui.upload
             , element = layui.element
             , layer = layui.layer
             , form = layui.form
             ,laydate = layui.laydate;

         //日期
         laydate.render({
             elem: '#date',
             type: 'date'
         });

          laydate.render({
             elem: '#date2',
             type: 'date'
         });







         // 表单提交(异步)
         form.on('submit(add)', function(data){

             console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}

             $.ajax({
                 url:"/member/update"
                 ,method:"post"
                 ,data:data.field
                 ,type:'post'
                 ,success:function(res){
                     console.log(res)
                     if(res.code == 0){

                         layer.msg('修改成功！',{icon:1,time:1000,scrollbar:false},function(){
                             parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                             window.parent.location.reload()
                         });

                     }else{
                         layer.msg('修改失败！',{icon:2,time:1000,scrollbar:false})
                     }
                 }
             })
             return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
         });
     })
 </script>

</body>
</html>